package com.uzai.console.web.locallive;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.taobao.api.internal.toplink.embedded.websocket.util.StringUtil;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.locallive.tlbtoken.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.locallive.TlbTokenService;
import com.uzai.console.vo.locallive.tlbtoken.TlbTokenInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 推老板账号
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "推老板账号",tags = "本地生活|授权管理|推老板账号")
@ApiSort(13)
@RestController
public class TlbTokenController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(TlbTokenController.class);

    @Autowired
    private TlbTokenService tlbTokenService;

    @ApiOperation(value = "分页查询推老板美团列表", notes = "分页查询推老板美团列表", response = TlbTokenInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/tlbToken/findTlbTokenList")
    public Object findTlbTokenList(@RequestBody TlbTokenQuery tlbTokenQuery){
       if(StringUtils.isBlank(tlbTokenQuery.getType())){
           tlbTokenQuery.setType("mt");
       }
        return tlbTokenService.findTlbTokenList(tlbTokenQuery);
    }

    @SystemLogType(model = SystemModelEnum.TlbToken, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加推老板美团账号", notes = "添加推老板美团账号")
    @ApiOperationSupport(order = 3)
    @PostMapping("/tlbToken/addTlbToken")
    public Object addTlbToken(@RequestBody TlbTokenInfoDto tlbTokenInfoDto){
         if(StringUtils.isBlank(tlbTokenInfoDto.getType())){
             tlbTokenInfoDto.setType("mt");
         }

         tlbTokenService.addTlbToken(tlbTokenInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TlbToken, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改推老板美团账号", notes = "修改推老板美团账号")
    @ApiOperationSupport(order = 4)
    @PostMapping("/tlbToken/updateTlbToken")
    public Object updateTlbToken(@RequestBody TlbTokenInfoDto tlbTokenInfoDto){
        tlbTokenService.updateTlbToken(tlbTokenInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TlbToken, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除", notes = "删除")
    @ApiOperationSupport(order = 5)
    @PostMapping("/tlbToken/deleteTlbToken")
    public Object deleteTlbToken(@RequestBody TlbTokenIdDto tlbTokenIdDto){
        tlbTokenIdDto.setType("mt");
        tlbTokenService.deleteTlbToken(tlbTokenIdDto);
        return true;
    }


}
